<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="./lib/themes/metro/easyui.css" />
    <link rel="stylesheet" href="./lib/themes/icon.css" />
</head>
<body>
    <div id="app" >
        <div id="menu" data-bind="component:{name:'ko-menu',params:{options:{inline:false}}}"></div>
        <test></test>
        <button data-bind="click:add">添加菜单</button> 
    </div>
    <script src="./lib/jquery.min.js"></script>
    <script src="./lib/jquery.easyui.min.js"></script>
    <script src="./lib/locale/easyui-lang-zh_CN.js"></script>
    <script src="./lib/knockout-3.5.0.js" ></script>
    <script src="/koeasyui.js"></script>
    <script>
        koeasyui.use(window.ko);
        ko.components.register('test',{
            template:'<div>a</div>',
            viewModel: function(){
                this.koDescendantsComplete=function(){
                    console.log('.................');
                }
            }
        });
        var i = 0;
        var rootVm={
            add:function(){
                var $menu = koeasyui.getContextFor(document.getElementById('menu'));       
                $menu.appendItem({
                    text: 'New Item',
                    iconCls: 'icon-ok',
                    onclick: function(){alert('New Item')}
                });
                $menu.show();
            },
            koDescendantsComplete:function(){
                console.log('.....');
            }
        };
        ko.applyBindings(rootVm, document.getElementById('app'));
    </script>
</body>
</html>